from ultralytics import YOLO

if __name__ == '__main__':
    # 加载YOLOv8模型  基于已有模型进行训练
    model = YOLO("yolov8n.pt")
    model.train(data='./data/mydata.yaml',epochs=51,device='cpu',workers=8)  # 训练次数 大于50
    metrics = model.val()  # 在验证集上评估模型性能
    results = model("./data/test/images/img_14.jpg")  # 对图像进行预测
    # Process results list
    for result in results:
        result.show()  # display to screen